{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from scipy import sparse as spsp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Construct a heterogeneous graph with one node type"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_nodes = 1000\n",
    "num_edges = 3000\n",
    "\n",
    "edata = []\n",
    "for i in range(3):\n",
    "    src = np.random.randint(0, num_nodes, num_edges)\n",
    "    dst = np.random.randint(0, num_nodes, num_edges)\n",
    "    etype = np.ones(num_edges) * i\n",
    "\n",
    "    src = np.expand_dims(src, 1)\n",
    "    dst = np.expand_dims(dst, 1)\n",
    "    etype = np.expand_dims(etype, 1)\n",
    "    edges = np.concatenate([src, dst, etype], 1)\n",
    "    edata.append(edges)\n",
    "edata = np.concatenate(edata, 0)\n",
    "np.savetxt('edges.csv', edata, fmt='%d', delimiter=',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "node_id = np.arange(num_nodes)\n",
    "ndata = np.random.randint(0, 10, num_nodes * 2).reshape(num_nodes, 2)\n",
    "node_id = np.expand_dims(node_id, 1)\n",
    "ndata = np.concatenate([node_id, ndata], 1)\n",
    "np.savetxt('node_data.csv', ndata, fmt='%d', delimiter=',')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Construct a heterogeneous graph with two node types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_nodes = 1000\n",
    "num_nodes1 = 100\n",
    "num_edges = 3000\n",
    "\n",
    "edata = []\n",
    "for i in range(2):\n",
    "    src = np.random.randint(0, num_nodes, num_edges)\n",
    "    dst = np.random.randint(0, num_nodes, num_edges)\n",
    "    etype = np.ones(num_edges) * i\n",
    "    src = np.expand_dims(src, 1)\n",
    "    dst = np.expand_dims(dst, 1)\n",
    "    etype = np.expand_dims(etype, 1)\n",
    "    edges = np.concatenate([src, dst, etype], 1)\n",
    "    edata.append(edges)\n",
    "    \n",
    "src = np.random.randint(0, num_nodes, num_edges)\n",
    "dst = np.random.randint(0, num_nodes1, num_edges)\n",
    "etype = np.ones(num_edges) * 2\n",
    "src = np.expand_dims(src, 1)\n",
    "dst = np.expand_dims(dst, 1)\n",
    "etype = np.expand_dims(etype, 1)\n",
    "edges = np.concatenate([src, dst, etype], 1)\n",
    "edata.append(edges)\n",
    "\n",
    "edata = np.concatenate(edata, 0)\n",
    "np.savetxt('edges1.csv', edata, fmt='%d', delimiter=',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "node_id = np.arange(num_nodes1)\n",
    "ndata = np.random.randint(0, 10, num_nodes1 * 3).reshape(num_nodes1, 3)\n",
    "node_id = np.expand_dims(node_id, 1)\n",
    "ndata = np.concatenate([node_id, ndata], 1)\n",
    "np.savetxt('node_data1.csv', ndata, fmt='%d', delimiter=',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
